using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class ColorStrip : Graphic
{
    public List<Color> colors;

    protected override void OnPopulateMesh(VertexHelper vh)
    {
        var (bl, tr) = UIMeshHelper.CalculateCorners(rectTransform);

        vh.Clear();

        var step = (tr.x - bl.x) / (colors.Count - 1);
        for (int i = 0; i < colors.Count - 1; i++)
        {
            UIMeshHelper.DrawRect(vh,
                new Vector2(bl.x + i * step, bl.y),
                new Vector2(bl.x + (i + 1) * step, tr.y),
                colors[i], colors[i],
                colors[i + 1], colors[i + 1]);
        }
    }
}
